
// 登录重定向地址
export const getRedirectUrl = (url?: string) => {
	const base = '/login?redirect=';
	if (!url) return `${base}${encodeURIComponent(window.location.href)}`;
	if (location.pathname === '/login') return '/login';
	return `${base}${url}`;
};

export const redirect = () => {
	const redirect = new URLSearchParams(location.search).get('redirect');
	if (redirect) {
		window.location.href = redirect;
	} else {
		window.location.href = '/';
	}
};
